<template>
    <div style="background-color: rgb(241 241 241);position: absolute;height: 100%;left: 0;top: 0;right: 0;">
        <div class="view">
            <div class="back-button" @click="goBack()" :style="'top:' + menuHeight + 'rpx'">
                <van-icon name="arrow-left" color="black" />
            </div>
            <image src="@/static/qqq.jpg" mode="aspectFill" class="img">
            </image>
            <div class="card">
                <van-card>
                    <view slot="title">
                        <van-row>
                            <van-col span="24">
                                <div class="phb2">
                                    <image src="@/static/15.png" mode="aspectFill" class="phb_img">
                                    </image>
                                </div>
                            </van-col>
                            <van-col span="24">
                                <div class="phb1">
                                    <image src="@/static/14.png" mode="aspectFill" class="phb_img">
                                    </image>
                                </div>
                            </van-col>
                            <van-col span="24">
                                <div class="phb3">
                                    <span>共 {{ list.length }} 人参与挑战</span>
                                </div>

                            </van-col>
                        </van-row>

                        <van-row>
                            <van-col span="24">
                                <div style="margin:20rpx 0 ;border-bottom: 1px solid #c7c7c7;"></div>
                            </van-col>
                        </van-row>
                        <van-row>
                            <van-col span="24" v-for="(item, index) in list" :key="index">
                                <van-row>
                                    <van-col span="2">
                                        <div class="phb4" v-if="index == 0">
                                            <image src="@/static/11.png" mode="aspectFill"
                                                style="width: 60rpx;height: 60rpx;line-height: 100rpx;">
                                            </image>
                                        </div>
                                        <div class="phb4" v-if="index == 1">
                                            <image src="@/static/12.png" mode="aspectFill"
                                                style="width: 42rpx;height: 60rpx;line-height: 100rpx;">
                                            </image>
                                        </div>
                                        <div class="phb4" v-if="index == 2">
                                            <image src="@/static/13.png" mode="aspectFill"
                                                style="width: 47rpx;height: 60rpx;line-height: 100rpx;">
                                            </image>
                                        </div>
                                        <div class="phb4" v-if="index > 2">
                                            <span class="text">
                                                {{ index }}
                                            </span>
                                        </div>
                                    </van-col>
                                    <van-col span="18">
                                        <div>
                                            <view>
                                                <image :src="item.pic" mode="aspectFill" class="pic">
                                                </image>
                                            </view>
                                            <view>
                                                <span class="text">
                                                    {{ item.name }}
                                                </span>
                                            </view>
                                        </div>
                                    </van-col>
                                    <van-col span="3">
                                        <span class="text" style="float: right;">
                                            {{ item.kilometers }}KM
                                        </span>
                                    </van-col>
                                </van-row>

                                <div style="margin:20rpx 0 ;border-bottom: 1px solid #c7c7c7;"></div>
                            </van-col>
                        </van-row>
                    </view>
                </van-card>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list: [],
            menu: '',
            menuHeight: ''
        }
    },
    // 检查用户是否登录？在哪个钩子函数
    onShow() {
        this.phblist()
        const menu = uni.getMenuButtonBoundingClientRect()
        const menuHeight = menu.top + menu.height + 8
        this.menuHeight = menuHeight
        this.menu = menu
        console.log(this.menu);
    },
    onLoad() {

    },
    methods: {
        phblist() {
            this.request({
                url: "/activity_config/charts",
                method: "get",
            }).then((res) => {
                this.list = res.data.data;
                console.log("排行版数据数据", this.list);
            });
        },
        goBack() {
            uni.switchTab({
                url: '/pages/my/index'
            })
        }
    }
}
</script>

<style  lang="scss" scoped>
.container {
    background-color: red;
}

.img {
    width: 100%;
    height: 600rpx;
    mask: linear-gradient(360deg, transparent, #fff);
}


.view {
    position: relative;
}

.card {
    position: relative;
    top: -240rpx;
    margin: 50rpx;
}

.card ::v-deep .van-card {
    border-radius: 10px;
    background-color: #ffffff !important;

}

.phb {
    background: #ffffff;
    width: 100%;
    height: 300rpx;
}

.phb_img {
    width: 100%;
    height: 100%;
}

.phb1 {
    width: 60%;
    height: 100rpx;
    margin: 0% 20%;
}

.phb2 {
    width: 200rpx;
    height: 37rpx;
    margin: 23rpx 201rpx;
}

.phb3 {
    width: 100%;
    height: 50rpx;
    text-align: center;
    color: rgb(78, 78, 78);
    font-size: 14px;
}

.phb4 {
    width: 100%;
    height: 90rpx;
    line-height: 133rpx;
}

.text {
    color: black;
    font-size: 17px;
    font-weight: bold;
    line-height: 100rpx;
}

.pic {
    float: left;
    overflow: hidden;
    display: block;
    width: 100rpx;
    height: 100rpx;
    border-radius: 50%;
    margin-right: 20rpx;
    margin-left: 20rpx;
}

.back-button {
    position: absolute;
    /* top: 5%; */
    left: 8%;
    height: 3%;
    width: 7%;
    background-color: #ffffff;
    z-index: 2;
    border-radius: 50%;
    line-height: 50rpx;
    text-align: center;
}
</style>